package cn.tedu.oop2;

/**
 * Time    : 2023/3/16 22:13
 * Author  : 王摇摆
 * FileName: Learn_MultiAttitude.java
 * Software: IntelliJ IDEA 2020.2.2
 * Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
 */

public class Learn_MultiAttitude {
    public static void main(String[] args) {
        //纯对象用来测试
//        Animal1 a = new Animal1();
//        Cat1 c = new Cat1();
//        Dog1 d = new Dog1();

        //多态的实现
        Animal1 a2 = new Cat1();
        Animal1 a3 = new Dog1();

        a2.eat();
        a3.eat();

        //a2.jump();//此句话报错
    }
}

class Animal1 {
    public void eat() {
        System.out.println("小动物喜欢吃零食~");
    }
}

class Cat1 extends Animal1 {
    @Override
    public void eat() {
        System.out.println("小猫喜欢吃小鱼");
    }

    public void jump() {
        System.out.println("小猫跳的很高");
    }

    public void say() {
        System.out.println("小猫会说喵喵喵");
    }
}

class Dog1 extends Animal1 {
    @Override
    public void eat() {
        System.out.println("小狗爱吃骨头");
    }

    public void run() {
        System.out.println("小狗跑的很快");
    }

    public void say() {
        System.out.println("小狗会说汪汪汪");
    }
}
